package com.doublethread.easymart.common.exception;

import com.doublethread.easymart.common.result.ResultCode;

/**
 * 商品模块异常工具类
 */
public class ProductException {

    /**
     * 商品不存在异常
     */
    public static void productNotFound() {
        throw new BusinessException(ResultCode.PRODUCT_NOT_FOUND);
    }

    /**
     * 商品库存不足异常
     */
    public static void outOfStock() {
        throw new BusinessException(ResultCode.PRODUCT_OUT_OF_STOCK);
    }

    /**
     * 商品已下架异常
     */
    public static void productDisabled() {
        throw new BusinessException(ResultCode.PRODUCT_DISABLED);
    }

    /**
     * 商品分类不存在异常
     */
    public static void categoryNotFound() {
        throw new BusinessException(ResultCode.CATEGORY_NOT_FOUND);
    }

    /**
     * 商品分类已禁用异常
     */
    public static void categoryDisabled() {
        throw new BusinessException(ResultCode.CATEGORY_DISABLED);
    }

    /**
     * 商品名称已存在异常
     */
    public static void productNameExists() {
        throw new BusinessException(ResultCode.PRODUCT_NAME_EXISTS);
    }

    /**
     * 分类下存在子分类异常
     */
    public static void categoryHasChildren() {
        throw new BusinessException(ResultCode.CATEGORY_HAS_CHILDREN);
    }

    /**
     * 分类下存在商品异常
     */
    public static void categoryHasProducts() {
        throw new BusinessException(ResultCode.CATEGORY_HAS_PRODUCTS);
    }

    /**
     * 分类名称已存在异常
     */
    public static void categoryNameExists() {
        throw new BusinessException(ResultCode.CATEGORY_NAME_EXISTS);
    }
}